<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />

    

    

    <title>使用docker安装oracle | 郑礼德技术栈</title>
    <meta name="author" content="郑礼德" />
    <meta name="keywords" content="" />
    <meta name="description" content="今天入职第一天，由于疫情在家办公连不上那边的数据库，要安装oracle ，不小心把oracle安装到外置硬盘去了，醉了，一顿操作怎么连都连不上，只能卸载了结果没卸干净，只能用docker骚操作一把了安装docker详见docker的安装基于docker 的 oracle安装拉取oracle镜像docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g运行docker镜像docker run -d -p 1521..." />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />

    
    <link rel="alternate" href="/homepage/atom.xml" title="郑礼德技术栈" type="application/atom+xml">
    
    
    <link rel="icon" href="/homepage/images/favicon.ico">
    

    <style type="text/css">
    @font-face {
        font-family: 'icomoon';
        src: url("/homepage/fonts/icomoon.eot?q628ml");
        src: url("/homepage/fonts/icomoon.eot?q628ml#iefix") format('embedded-opentype'),
             url("/homepage/fonts/icomoon.ttf?q628ml") format('truetype'),
             url("/homepage/fonts/icomoon.woff?q628ml") format('woff'),
             url("/homepage/fonts/icomoon.svg?q628ml#icomoon") format('svg');
        font-weight: normal;
        font-style: normal;
    }
    </style>
    
<link rel="stylesheet" href="/homepage/css/style.css">


    <!--[if lt IE 9]>
    <style type="text/css">
    .nav-inner {top:0;}
    .author-meta {position:static;top:0;}
    .search-form {height:36px;}
    </style>
    <script type="text/javascript" src="https://unpkg.com/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <![endif]-->
<meta name="generator" content="Hexo 4.2.0"></head>
<body>

    <main class="app">
        <header id="header" class="header clearfix">
    <div id="nav" class="nav">
    <div class="nav-mobile">
        <button id="open-panel" class="open-panel nav-mobile-item"><i class="icon-documents"></i></button>
        <h1 class="nav-mobile-title nav-mobile-item">郑礼德技术栈</h1>
        <button id="open-menus" class="open-panel nav-mobile-item"><i class="icon-library"></i></button>
    </div>

    <nav id="nav-inner" class="nav-inner">
        
            <a class="nav-item" href="/homepage/">
                <span class="nav-text">首页</span>
            </a>
        
            <a class="nav-item" href="/homepage/categories/front-end">
                <span class="nav-text">前端</span>
            </a>
        
            <a class="nav-item" href="/homepage/categories/back-end">
                <span class="nav-text">后端</span>
            </a>
        
            <a class="nav-item" href="/homepage/categories/linux">
                <span class="nav-text">linux部署</span>
            </a>
        
            <a class="nav-item" href="/homepage/tags">
                <span class="nav-text">标签</span>
            </a>
        
            <a class="nav-item" href="/homepage/archives">
                <span class="nav-text">归档</span>
            </a>
        
            <a class="nav-item" href="/homepage/about">
                <span class="nav-text">关于</span>
            </a>
        
    </nav>
</div>

    <aside id="aside" class="aside">
    <div id="aside-mask" class="aside-mask"></div>
    <div id="aside-inner" class="aside-inner">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"><i class="icon-search-stroke"></i></button><input type="hidden" name="sitesearch" value="http://zhenglide.gitee.io/homepage"></form>

        
        
        
        

        
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#安装docker"><span class="toc-number">1.</span> <span class="toc-text">安装docker</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#基于docker-的-oracle安装"><span class="toc-number">2.</span> <span class="toc-text">基于docker 的 oracle安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#拉取oracle镜像"><span class="toc-number">2.1.</span> <span class="toc-text">拉取oracle镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#运行docker镜像"><span class="toc-number">2.2.</span> <span class="toc-text">运行docker镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#进入docker镜像进行配置"><span class="toc-number">2.3.</span> <span class="toc-text">进入docker镜像进行配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#进入oracle命令环境"><span class="toc-number">2.3.1.</span> <span class="toc-text">进入oracle命令环境</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#切换到oracle-root用户-下"><span class="toc-number">2.3.2.</span> <span class="toc-text">切换到oracle root用户 下</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#编辑-etc-profile-文件配置环境变量"><span class="toc-number">2.3.3.</span> <span class="toc-text">编辑&#x2F;etc&#x2F;profile 文件配置环境变量</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#创建软连接"><span class="toc-number">2.3.4.</span> <span class="toc-text">创建软连接</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#切换回oracle用户"><span class="toc-number">2.3.5.</span> <span class="toc-text">切换回oracle用户</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#登录sqlplus–修改sys、system用户密码–创建用户"><span class="toc-number">2.3.6.</span> <span class="toc-text">登录sqlplus–修改sys、system用户密码–创建用户</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#使用pl-sql-连接"><span class="toc-number">2.4.</span> <span class="toc-text">使用pl&#x2F;sql 连接</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#配置环境变量"><span class="toc-number">2.4.1.</span> <span class="toc-text">配置环境变量</span></a></li></ol></li></ol></li></ol>
        
    </div>
</aside>

</header>

        <div id="content" class="content">
            <div id="wrapper" class="wrapper" style="max-width: 800px">
                <article class="article" itemscope itemprop="blogPost">
    
    <header class="article-header">
        
        <h1 itemprop="name">
            使用docker安装oracle
        </h1>
        
        <div class="article-meta clearfix">
            <a class="article-date" href="http://zhenglide.gitee.io/homepage/2020/04/13/%E4%BD%BF%E7%94%A8docker%E5%AE%89%E8%A3%85oracle/index.html">
    
    <i class="icon-calendar"></i>
    
    <time datetime="2020-04-13T09:54:21.000Z" itemprop="datePublished">2020-04-13</time>
</a>

            
<div class="article-tag-list">
    <i class="icon-tag"></i>
    <a class="article-tag-link" href="/homepage/tags/docker/" rel="tag">docker</a>, <a class="article-tag-link" href="/homepage/tags/oracle/" rel="tag">oracle</a>
</div>


        </div>
    </header>
    
    <section class="article-body markdown-body">
        
        <p>今天入职第一天，由于疫情在家办公连不上那边的数据库，要安装oracle ，不小心把oracle安装到外置硬盘去了，醉了，一顿操作怎么连都连不上，只能卸载了结果没卸干净，只能用docker骚操作一把了</p>
<a id="more"></a>

<h2 id="安装docker"><a href="#安装docker" class="headerlink" title="安装docker"></a>安装docker</h2><p>详见docker的安装</p>
<h2 id="基于docker-的-oracle安装"><a href="#基于docker-的-oracle安装" class="headerlink" title="基于docker 的 oracle安装"></a>基于docker 的 oracle安装</h2><h3 id="拉取oracle镜像"><a href="#拉取oracle镜像" class="headerlink" title="拉取oracle镜像"></a>拉取oracle镜像</h3><p><code>docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g</code></p>
<h3 id="运行docker镜像"><a href="#运行docker镜像" class="headerlink" title="运行docker镜像"></a>运行docker镜像</h3><p><code>docker run -d -p 1521:1521 --restart=always  --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g</code></p>
<h3 id="进入docker镜像进行配置"><a href="#进入docker镜像进行配置" class="headerlink" title="进入docker镜像进行配置"></a>进入docker镜像进行配置</h3><h4 id="进入oracle命令环境"><a href="#进入oracle命令环境" class="headerlink" title="进入oracle命令环境"></a>进入oracle命令环境</h4><p><code>docker exec -it oracle11g /bin/bash</code></p>
<h4 id="切换到oracle-root用户-下"><a href="#切换到oracle-root用户-下" class="headerlink" title="切换到oracle root用户 下"></a>切换到oracle root用户 下</h4><p><code>su root</code></p>
<p>密码：helowin</p>
<h4 id="编辑-etc-profile-文件配置环境变量"><a href="#编辑-etc-profile-文件配置环境变量" class="headerlink" title="编辑/etc/profile 文件配置环境变量"></a>编辑/etc/profile 文件配置环境变量</h4><pre><code>export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=ORACLE_HOME/bin:$PATH</code></pre><h4 id="创建软连接"><a href="#创建软连接" class="headerlink" title="创建软连接"></a>创建软连接</h4><p><code>ln -s $ORACLE_HOME/bin/sqlplus /usr/bin</code></p>
<h4 id="切换回oracle用户"><a href="#切换回oracle用户" class="headerlink" title="切换回oracle用户"></a>切换回oracle用户</h4><p><code>su - oracle</code></p>
<h4 id="登录sqlplus–修改sys、system用户密码–创建用户"><a href="#登录sqlplus–修改sys、system用户密码–创建用户" class="headerlink" title="登录sqlplus–修改sys、system用户密码–创建用户"></a>登录sqlplus–修改sys、system用户密码–创建用户</h4><p><code>sqlplus /nolog</code></p>
<p><code>conn /as sysdba</code></p>
<p>修改密码：<br><code>alter user system identified by oracle;</code><br><code>alter user sys identified by oracle;</code><br><code>ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;</code><br>创建用户<br><code>create user test identified by test;</code><br>并给用户赋予权限<br><code>grant connect,resource,dba to test;</code></p>
<h3 id="使用pl-sql-连接"><a href="#使用pl-sql-连接" class="headerlink" title="使用pl/sql 连接"></a>使用pl/sql 连接</h3><h4 id="配置环境变量"><a href="#配置环境变量" class="headerlink" title="配置环境变量"></a>配置环境变量</h4><p>ORACLE_HOME     E:\instantclient_11_2</p>
<p>TNS_ADMIN  E:\instantclient_11_2\ADMIN</p>
<p>在E:\instantclient_11_2\ADMIN 修改 .ora 文件</p>
<pre><code>docker_oracle11 =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 112.74.28.55)(PORT =1521))
   )
   (CONNECT_DATA =
     (SERVICE_NAME = helowinXDB)
   )
)</code></pre><p>之后打开plsql 进行连接</p>
<img src="/homepage/2020/04/13/%E4%BD%BF%E7%94%A8docker%E5%AE%89%E8%A3%85oracle/plsql%E8%BF%9E%E6%8E%A5%E6%88%90%E5%8A%9F.png" class="">
        
    </section>
</article>



<a id="pagenext" href="/homepage/2020/04/13/springcloud-admin%E7%9B%91%E6%8E%A7%E6%A8%A1%E5%9D%97%E6%90%AD%E5%BB%BA/" class="article-next" title="springcloud-admin监控模块搭建"><i class="icon-arrow-right"></i></a>


<a id="pageprev" href="/homepage/2020/04/20/mybaties-plus3-x%E6%95%B4%E5%90%88springboot%E6%90%AD%E5%BB%BA%E9%A1%B9%E7%9B%AE%E5%9F%BA%E7%A1%80%E6%A1%86%E6%9E%B6/" class="article-prev" title="mybaties-plus3.x整合springboot搭建项目基础框架"><i class="icon-arrow-left"></i></a>




            </div>
        </div>
        <footer class="footer">
    Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>, Theme by <a href="https://github.com/sanonz/hexo-theme-concise" target="_blank">Concise</a>

    
    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?b13bb4c2ef8300062aab9732bd22eae0";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
    
</footer>

    </main>

    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript">
    $(function() {
        var nodes = {
            nav: $('#nav'),
            aside: $('#aside'),
            asideInner: $('#aside-inner'),
            navInner: $('#nav-inner')
        };

        var doing = false;
        nodes.asideInner.on('webkitAnimationEnd mozAnimationEnd oAnimationEnd oanimationend animationend', function() {
            if (nodes.aside.hasClass('mobile-open')) {
                nodes.aside.removeClass('mobile-open');
            } else {
                nodes.aside.removeClass('mobile-close panel-show');
            }
            doing = false;
        });
        $('#open-panel, #aside-mask').on('click', function() {
            if (doing) {
                return;
            }

            if (nodes.aside.hasClass('panel-show')) {
                nodes.aside.addClass('mobile-close');
            } else {
                nodes.aside.addClass('mobile-open panel-show');
            }
        });
        $('#open-menus').on('click', function() {
            nodes.navInner.slideToggle();
        });

        if (window.innerWidth <= 960) {
            setTimeout(function() {
                nodes.navInner.slideUp();
            }, 3000);
        }
    });
    </script>
    
        
<script src="/homepage/js/scrollspy.min.js"></script>

        <script type="text/javascript">
        $(document.body).scrollspy({target: '#aside-inner'});

        $(window).on('resize', function() {
            var hw = $('#header').width();
            var ww = $('#wrapper').width();
            var space = ($(this).width() - hw - ww) / 2 / 2;

            var pageprev = $('#pageprev');
            var pagenext = $('#pagenext');
            var avg = (pageprev.width() + pagenext.width()) / 2

            if(space > avg) {
                var len = space - avg / 2;
                var styles = {position: 'fixed', top: '50%', marginTop: - (pageprev.width() + pagenext.width()) / 4}
                pageprev.css($.extend({left: hw + len}, styles));
                pagenext.css($.extend({right: len}, styles));
            } else {
                pageprev.removeAttr('style');
                pagenext.removeAttr('style');
            }
        }).trigger('resize');
        </script>
    

</body>
</html>
